home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HamCall (October 1991)
/
HamCall (Whitehall Publishing)(1991).bin
/
prgming
/
ada
/
sdepdg.ada
< prev
next >
Wrap
Text File
|
1987-10-19
|
5KB
|
170 lines
--
-- I/O System Dependencies Package for MV 10000, ROLM Ada Development
-- Environment, AOS Operating System
--
-- This visible section is derived from SYSDEP_SPEC.ADA by Stewart French, TI
-- Derivation by Richard Conn, TI
--
package SYSDEP is
--
-- Open the console for binary I/O, no echo
--
procedure OPEN_CONSOLE;
pragma INLINE (OPEN_CONSOLE);
--
-- Close the console, resetting parameters to their original condition
--
procedure CLOSE_CONSOLE;
pragma INLINE (CLOSE_CONSOLE);
--
-- Put a character to the terminal. There should be no translation of the
-- characters. There may be exceptions to this rule (like CTRL-S and
-- CTRL-Q for flow control), and these exceptions must be identified in
-- IS_VALID_CHARACTER below.
--
procedure PUT (CHAR : CHARACTER);
pragma INLINE (PUT);
--
-- Get a character from the terminal keyboard with no echo and no
-- translations.
--
procedure GET (CHAR : out CHARACTER);
pragma INLINE (GET);
--
-- Returns a boolean indicating whether the character is safe to use in the
-- environment. Suspicious characters may be CTRL-S, CTRL-Q, CTRL-C, CTRL-Y.
--
function IS_VALID_CHARACTER (CHAR : CHARACTER) return BOOLEAN;
pragma INLINE (IS_VALID_CHARACTER);
end SYSDEP;
with TTY_IO,
SYS_CALLS,
FILE_DEFINITIONS,
FILE_IO,
BIT_OPS;
package body SYSDEP is
BUFFER_BYTE_PTR : INTEGER;
BUFFER : INTEGER;
INVALID_CHARS_ARRAY : array (1 .. 8) of CHARACTER;
TERMINAL : FILE_DEFINITIONS.CHANNEL_NUMBER;
TTY : TTY_IO.FILE_TYPE;
--
procedure OPEN_CONSOLE is
CONSOLE_CHARACTERISTICS : FILE_IO.DEVICE_CHARACTERISTICS;
ERROR_CODE : INTEGER;
AC0, AC1, AC2 : INTEGER;
NAME : SYS_CALLS.CALL_NAME;
ERROR_ID : SYS_CALLS.ERROR_CODE;
begin
TTY_IO.OPEN (TTY, TTY_IO.INOUT_FILE, "@console");
-- turn off the keyboard interrupt capabilities
AC0 := 0;
AC1 := 0;
AC2 := 0;
NAME := SYS_CALLS.KIOFF;
SYS_CALLS.LONG_SYS (NAME, AC0, AC1, AC2, ERROR_ID);
FILE_IO.OPEN
("@console", TERMINAL, ERROR_CODE,
FILE_DEFINITIONS.OPEN_FOR_INPUT_OUTPUT +
FILE_DEFINITIONS.BINARY_IO + FILE_DEFINITIONS.VARIABLE_LENGTH);
FILE_IO.GET_CHARACTERISTICS
(TERMINAL, CONSOLE_CHARACTERISTICS, ERROR_CODE);
CONSOLE_CHARACTERISTICS.ECHO := FILE_IO.NO_ECHO;
CONSOLE_CHARACTERISTICS.CHARACTERISTICS
(FILE_IO.NON_ANSI_STANDARD_DEVICE) := FALSE;
FILE_IO.SET_CHARACTERISTICS
(TERMINAL, CONSOLE_CHARACTERISTICS, ERROR_CODE);
BUFFER_BYTE_PTR := INTEGER'VAL (BUFFER'ADDRESS);
BUFFER_BYTE_PTR := BIT_OPS.LEFT_SHIFT_BY_1 (BUFFER_BYTE_PTR);
end OPEN_CONSOLE;
-- pragma inline (OPEN_CONSOLE);
--
procedure CLOSE_CONSOLE is
ERROR_CODE : INTEGER;
begin
FILE_IO.CLOSE (TERMINAL, ERROR_CODE);
end CLOSE_CONSOLE;
-- pragma inline (CLOSE_CONSOLE);
--
procedure PUT (CHAR : CHARACTER) is
DATA : STRING (1 .. 1);
begin
DATA (1) := CHAR;
TTY_IO.PUT (TTY, DATA);
end PUT;
-- pragma inline (PUT);
--
procedure GET (CHAR : out CHARACTER) is
BYTES_READ : INTEGER;
ERROR_CODE : INTEGER;
begin
FILE_IO.READ
(TERMINAL, ERROR_CODE, BYTES_READ, BUFFER_BYTE_PTR,
FILE_DEFINITIONS.BINARY_IO, 1);
BUFFER := BIT_OPS.LOGICAL_RIGHT_SHIFT (BUFFER, 24);
CHAR := CHARACTER'VAL (BUFFER);
end GET;
-- pragma inline (GET);
--
function IS_VALID_CHARACTER (CHAR : CHARACTER) return BOOLEAN is
VALID_FLAG : BOOLEAN;
begin
VALID_FLAG := TRUE;
for I in 1 .. 8 loop
if INVALID_CHARS_ARRAY (I) = CHAR then
VALID_FLAG := FALSE;
end if;
end loop;
return VALID_FLAG;
end IS_VALID_CHARACTER;
-- pragma inline (IS_VALID_CHARACTER);
begin
-- please refer to AOS/VS Programmer's Manual, Volume 1, System Concepts
-- page 5-20 for a description of these character codes.
INVALID_CHARS_ARRAY (4) := ASCII.DC3; -- CTRL-S
INVALID_CHARS_ARRAY (5) := ASCII.DC1; -- CTRL-Q
end SYSDEP;